package sort;

import java.util.Arrays;

public class sortDeom6 {
        public static void main(String[] args) {
            int[] a = {90,89,34,12,34,67,45};
            bubbleSort(a);
            System.out.println(Arrays.toString(a));
        }
    
        private static void bubbleSort(int[] a) {
            for (int i = 0; i < a.length - 1; i++) {
                boolean flag = false;
                for (int j = 0; j < a.length - 1 - i; j++) {
                    if(a[j] > a[j+1]){
                        swap(a,j,j+1);
                        flag = true;
                    }
                }
                if(flag == false){
                    break;
                }
            }
        }
    
        private static void swap(int[] a, int j, int i) {
            int tmp = a[j];
            a[j] = a[i];
            a[i] = tmp;
        }
    }